//
//  CellOfDoubleImage.m
//  ProjectA_ManualGuest
//
//  Created by dingcong on 16/6/14.
//  Copyright © 2016年 丁聪. All rights reserved.
//

#import "CellOfDoubleImage.h"
#import "Masonry.h"
#import "PrefixHeader.pch"
#import "UIImageView+WebCache.h"
#import "AppDelegate.h"

@implementation CellOfDoubleImage

- (void)awakeFromNib {
    // Initialization code
}



- (void)dealloc{
    
    [_firstImage release];
    [_SecondImage release];
    [_model release];
    [_tap release];
    [super dealloc];
    
    
    
}

#pragma 重写初始化并创建

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self creat];
        self.backgroundColor = [UIColor clearColor];
    }
    
    return self;
}

- (void)creat
{
    
    self.firstImage = [[UIImageView alloc]init];
    
    [self.contentView addSubview:self.firstImage];
    [self.firstImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(0);
        make.leading.equalTo(self.contentView.mas_leading).offset(0);
        
        make.height.equalTo(self.contentView.mas_height);
        make.width.offset(SCREEN_WIDTH / 2);
        
    }];
    
    self.tap2 = [[UITapGestureRecognizer alloc]init];
    self.firstImage.userInteractionEnabled = YES;
    [self.firstImage addGestureRecognizer:self.tap2];
    [self.tap2 release];
    
    
//    self.firstImage.backgroundColor = [UIColor greenColor];
    
    self.firstImage.layer.cornerRadius = 19;
    [self.firstImage release];
    
    self.SecondImage = [[UIImageView alloc]init];
    [self.contentView addSubview:self.SecondImage];
    [self.SecondImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.firstImage.mas_trailing).offset(5);
        make.height.equalTo(self.firstImage.mas_height);
        make.width.equalTo(self.firstImage.mas_width);
        make.centerY.equalTo(self.firstImage.mas_centerY);
    }];
    
    self.tap = [[UITapGestureRecognizer alloc]init];
    self.SecondImage.userInteractionEnabled = YES;
    [self.SecondImage addGestureRecognizer:self.tap];
    [self.tap release];
//    self.SecondImage.backgroundColor = [UIColor greenColor];
    
    
    
    
}




- (void)setModel:(SelectionModel *)model
{
    
    NSLog(@"Doble:%@", model.link_type);
    
    if ([model.link_type isEqualToString:@"shijiMaterialTopic"])
    {
        [self.firstImage sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:[UIImage imageNamed:@"13.png"]];
    }
    else if([model.link_type isEqualToString:@"courseTopic"])
    {
        [self.SecondImage sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:[UIImage imageNamed:@"13.png"]];
        
    }
    
    
    
    
}






@end
